﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Zombicide.UI.VM;
using Zombicide.Business;
using Zombicide.Model;

namespace Zombicide.UI.WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainWindowViewModel viewModel = new MainWindowViewModel();

        //public Board Board { get; set; }
        //public List<Hero> Heroes { get; set; }

        public MainWindow()
        {
            //Init();
            InitializeComponent();
            DataContext = viewModel;
        }

        #region Event

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RefreshTiles();
        }

        private void Deploy_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void ListHeroes_Selected(object sender, RoutedEventArgs e)
        {
            ActivateStartZone();
        }

        #endregion

        #region Method

        public void Init()
        {
            ////Board
            //BoardService boardService = new BoardService();
            //Board = boardService.GenerateBoard(BoardLevel.Green);

            ////Heroes
            //HeroService heroService = new HeroService();
            //Heroes = new List<Hero>();
            //for (int i = 0; i < 4; i++)
            //{
            //    Heroes.Add(heroService.GenerateRandomHero());
            //}
        }

        public void RefreshTiles()
        {
            //var tile = Board.Tiles.FirstOrDefault();
            //UCTile UcTile = new UCTile(this,tile);
            //GridBoard.Children.Add(UcTile);
        }
                
        public void ActivateStartZone()
        {
            //foreach (var ucTile in GridBoard.Children)
            //{
            //    ((UCTile)ucTile).ActiveStartZone();
            //}
        }

        public void AddHero(Square square)
        {
            /*var tile = GridBoard.Children[0] as UCTile;
            foreach (var item in tile.Tile.Squares)
            {
                if (item)
                {
                    
                }
            }*/
            // --> Binding pour solution les problemes de refresh
        }

        #endregion
    }
}
